<template>
<div>
    <b-modal id="modal-CurrentUserPassword" centered title="修改用户密码" hide-footer>
        <b-form>

            <el-row>
                <el-col :span="24">
                    <div class="grid-content bg-purple-dark">
                        <el-input placeholder="输入原密码" v-model="user.originalPassword" show-password></el-input>
                    </div>
                </el-col>
            </el-row>
            <div style="margin-top:10px"></div>
            <el-row>
                <el-col :span="24">
                    <div class="grid-content bg-purple-dark">
                        <el-input placeholder="设置密码" v-model="user.password" show-password></el-input>
                    </div>
                </el-col>
            </el-row>
            <div style="margin-top:10px"></div>
            <el-row>
                <el-col :span="24">
                    <div class="grid-content bg-purple-dark">
                        <el-input placeholder="请确认您的密码" v-model="user.confirmPassword" show-password></el-input>
                    </div>
                </el-col>
            </el-row>
            <div style="margin-top:10px"></div>
            <el-row :gutter="20">
                <el-col :span="6">
                    <div class="grid-content bg-purple">
                        <el-button type="primary" @click="Changethepassword">修改密码</el-button>
                    </div>
                </el-col>
            </el-row>
        </b-form>
    </b-modal>
</div>
</template>

<script>
export default {
    name: "modal-CurrentUserPassword",
    data() {
        return {
            input: "",
            user: {
                originalPassword: "",
                confirmPassword: "",
                password: "",

            }
        }
    },
    methods: {
        Changethepassword() {
            console.log(this.user);
            if (this.user) {
                this.$userApi.modifyingCurrentUserPassword(this.user).then((res) => {
                    console.log(res);
                    if (res.data) {
                        this.$router.push({
                            name: "Login"
                        })
                    } else {
                        if (res.originalPassword) {
                            this.$message({
                                message: res.originalPassword,
                                type: 'error',
                            })
                        }
                        if (res.password) {
                            this.$message({
                                message: res.password,
                                type: 'error',
                                offset: 60
                            })
                        }
                    }

                })
            }
        }
    }

}
</script>

<style >

</style>
